package com.lzj.demo.design.template.fzw;

import cn.hutool.core.collection.CollectionUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

@Slf4j
/**
 * 基础电商推广服务
 * 1.生成海报
 * 2.海报含带推广邀请码
 * */
//定义执行顺序的抽象类
public abstract class NetMail {
    /**
     * 用户名
     * */
    private Long uid;
    /**
     * 用户密码
     * */
    private String uPassword;

    public NetMail(Long uid, String uPassword) {
        this.uid = uid;
        this.uPassword = uPassword;
    }

    /**
     * 生成商品推广海报
     * */
    public String generateGoodsPoster(String skuUrl){
        //①模拟登录
        if(!login(uid,uPassword)){
            return null;
        }
        //②爬取信息
        Map<String,String> goodsInfo = reptile(skuUrl);
        if(CollectionUtil.isEmpty(goodsInfo)){
            return null;
        }
        //③生成海报
        return createBase64(goodsInfo);
    }

    /**
     * 模拟登录
     * */
    protected abstract Boolean login(Long uid,String uPassword);
    /**
     * 爬取信息
     * */
    protected abstract Map<String,String> reptile(String skuUrl);
    /**
     * 生成海报
     * */
    protected abstract String createBase64(Map<String,String> goodsInfo);

}
